<?php
namespace App\Repositories;

use App\Link;
use App\Repositories\BaseRepository;

class LinkRepository {
	use BaseRepository;

	protected $model, $table_name;

	public function __construct(Link $link) {
		$this->model = $link;
		$this->table_name = 'links';
	}

	protected function searchColumn($query, $where) {
		return $query->when(array_key_exists('title', $where), function ($query) use ($where) {
			return $query->where('title', 'like', "%{$where['title']}%");
		})->when(array_key_exists('website', $where), function ($query) use ($where) {
			return $query->where('website', 'like', "%{$where['website']}%");
		});
	}
}